home *** CD-ROM | disk | FTP | other *** search
- Path: garden.csc.calpoly.edu!not-for-mail
- From: dstubbs@garden.csc.calpoly.edu (Dan Stubbs)
- Newsgroups: comp.lang.c
- Subject: Re: String Question
- Date: 16 Mar 1996 09:58:40 -0800
- Organization: Cal Poly, San Luis Obispo
- Message-ID: <4ievgg$qcg@garden.csc.calpoly.edu>
- References: <DoBt0E.4A9@freenet.carleton.ca>
- NNTP-Posting-User: dstubbs@garden.csc.calpoly.edu
-
- In article <DoBt0E.4A9@freenet.carleton.ca>,
- Jerry Boyd <aq436@FreeNet.Carleton.CA> wrote:
- >
- >
- >How would I write a function to remove a specified
- >number of characters from a string and store it in an array.
- >For instance, extracting three characters from a string, starting
- >from the 5th character.
- >
- >
-
- void remove (char A[], char B[], int p, int q, int n) {
- /*
- * Delete p characters from A beginning with the qth character.
- * Copy the deleted characters to B. Assume that A starts with
- * n characters and that n >= (p+q) - 1.
- */
- memcpy (B, A+q-1, p);
- memmove (A+q-1, A+q+p-1, n-(p+q)+1);
- }
-
-